<?php
namespace app\admin\model;
use think\Model;
use think\Db;
use app\admin\model\Department as departmentModel;
use app\admin\model\Location as locationModel;
class Equipment extends Model
{
    private $fields = array('equipment','equipment_code','department_code','location_id','remark','video_url');
    protected $table = 'tp_equipment';

    function mainAllList(){
        $departmentModel = new departmentModel();
        $locationModel = new locationModel();
        $where[] = ['is_del','=',0];
        $list = $this->where($where)->order('id desc')->select();
        foreach($list as &$v){
            $department = $departmentModel->where(array('department_code'=>$v['department_code']))->find();
            $v['department'] = $department['department'];
            $location = $locationModel->where(array('id'=>$v['location_id']))->find();
            $v['location'] = $location['location'];
        }

        return $list;
    }

    //处理参数
    function disposeData($data,$act=''){

        $newData = array_elements($this->fields, $data);

        return $newData;
    }
}